﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Wicresoft.SMS.Data;

namespace Wicresoft.SMS.OMSService
{
    public class DBLog
    {
        private static LogService logService;

        private static readonly string productname = "OMSService";
        
        private static void WriteLog(string type, string msg)
        {
            try
            {
                if (logService == null)
                {
                    IConnectStringProvider connectProvider = new WebConfigProvider();
                    logService = new LogService(connectProvider.ConnectionString); 
                }
                logService.WriteLog(DateTime.Now, productname, type, msg, "OMSService");
            }
            catch (Exception)
            {

            }

        }

        public static void Exception(string msg)
        {
            WriteLog("Exception", msg);
        }

        public static void Exception(string msg, Exception ex)
        {
            WriteLog("Exception", msg + " ex:" + ex.ToString());
        }

        public static void Debug(string msg)
        {
            WriteLog("Debug", msg);
        }

        public static void Info(string msg)
        {
            WriteLog("Info", msg);
        }
    }
}